package org.template.mainpackage;

import org.hibernate.Session;
import org.template.portal.Student;
import org.template.portal.StudentGroup;
import org.template.portal.YearGroup;

public class HibernateTemplate {

  public HibernateTemplate() {
    try {
      System.out.println("Maven + Hibernate + MySQL");
      Session session = HibernateUtil.getSessionFactory().openSession();

      session.beginTransaction();

      Student student = new Student();
      student.setName("trollll");
      session.save(student);

      YearGroup yearGroup = new YearGroup();
      yearGroup.setName("grouuuuup");

      session.save(yearGroup);

      StudentGroup studentGroup = new StudentGroup();
      studentGroup.setYearGroup(yearGroup);

      studentGroup.setStudent(student);
      session.save(studentGroup);

      // Student student = new Student();
      // Ad ad = new Ad();
      // Category category = new Category();
      // Course course = new Course();
      // Faculty faculty = new Faculty();
      // MainPagePost mainPagePost = new MainPagePost();
      // Comment comment = new Comment();
      // Location location = new Location();
      // Question question = new Question();
      // Opinion opinion = new Opinion();
      // Answer answer = new Answer();
      // Sgroup group = new Sgroup();
      // session.save(group);
      // session.save(student);
      //
      // StudentGroup studentGroup = new StudentGroup();
      // studentGroup.setGroup(group);
      // studentGroup.setStudent(student);
      // session.save(studentGroup);
      //
      // Set ads = new HashSet();
      // Set comments = new HashSet();
      // Set locations = new HashSet();
      // Set questions = new HashSet();
      // Set opinions = new HashSet();
      // Set answers = new HashSet();
      // Set courses = new HashSet();
      // Set students = new HashSet();
      //
      // comments.add(comment);
      // locations.add(location);
      // questions.add(question);
      // opinions.add(opinion);
      // answers.add(answer);
      // courses.add(course);
      // ads.add(ad);
      // students.add(student);
      //
      // student.setName("Rafal");
      // student.setEmail("realgwyn@gmail.com");
      // student.setAds(ads);
      // student.setComments(comments);
      // student.setQuestions(questions);
      // student.setLocations(locations);
      // student.setAnswers(answers);
      // student.setCourses(courses);
      // student.setOpinions(opinions);
      // student.getStudentGroups().add(studentGroup);
      //
      // ad.setContent("kupie internet");
      // ad.setTitle("kupie");
      // ad.setCategory(category);
      // ad.setStudent(student);
      //
      // answer.setQuestion(question);
      // answer.setStudent(student);
      // answer.setContent("hahahahaha");
      //
      // category.setAds(ads);
      // category.setName("kupie/sprzedam");
      //
      // comment.setStudent(student);
      // comment.setMainPagePost(mainPagePost);
      // comment.setContent("trolololo comment");
      // comment.setBadVoteCount(10);
      //
      // course.setFaculty(faculty);
      // course.setName("kurs trollowni");
      // course.setStudents(students);
      //
      // faculty.setCourses(courses);
      // faculty.setName("wydzial figli i psot");
      //
      // location.setStudent(student);
      // location.setContent("to jest fajna miejscowka");
      // location.setTitle("fajna miejscowa");
      // location.setOpinions(opinions);
      //
      // mainPagePost.setStudent(student);
      // mainPagePost.setComments(comments);
      // mainPagePost.setTitle("to jest post");
      // mainPagePost.setContent("fhashdhfashfuehufhuhu huhueheuheueh");
      //
      // opinion.setStudent(student);
      // opinion.setLocation(location);
      // opinion.setContent("gowno prawda, cwelu!");
      //
      // question.setStudent(student);
      // question.setAnswers(answers);
      // question.setContent("co ja pacze?");
      //
      // answer.setContent("lubisz paczec jak pacze!");
      // answer.setStudent(student);
      //
      // session.save(answer);
      // session.save(opinion);
      // session.save(location);
      // session.save(question);
      // session.save(student);
      // session.save(ad);
      // session.save(category);
      // session.save(course);
      // session.save(faculty);
      // session.save(comment);
      // session.save(mainPagePost);
      session.getTransaction().commit();

    } catch (Exception ex) {
      ex.printStackTrace();
    }

  }

  public static void main(String[] args) {
    new HibernateTemplate();
  }
}
